package com.derbysoft.defender.api.requester;

import com.derbysoft.defender.api.response.OAuth2AccessToken;
import com.derbysoft.defender.util.AuthorizationUtil;

/**
 * <p>some description here.</p>
 * Created by Afee Lee on 2017-03-26 14:36
 *
 * @author Afee Lee
 * @version 1.0
 * @see Object
 * @since 1.8
 */
public class AccessTokenRequester extends AbstractRequester {
    private String clientId;
    private String clientSecret;

    public AccessTokenRequester(String clientId, String clientSecret) {
        this.clientId = clientId;
        this.clientSecret = clientSecret;
    }

    public OAuth2AccessToken request(String tokenUrl) {
        return postForEntity(tokenUrl, null, AuthorizationUtil.basic(clientId, clientSecret), OAuth2AccessToken.class)
                .initExpires();
    }
}
